package com.common.result;


import org.springframework.http.HttpStatus;

/*
* 统一返回结果类
* */
public class ResponseVO {

    private Object data;

    private Integer code;

    private String msg;

    public static ResponseVO success(){
        return success(null);
    }


    public static ResponseVO success(Object data){
        ResponseVO responseVO = new ResponseVO();
        responseVO.setCode(HttpStatus.OK.value());
        responseVO.setMsg(HttpStatus.OK.name());
        responseVO.setData(data);
        return responseVO;
    }

    public static ResponseVO error(String msg){
        ResponseVO responseVO = new ResponseVO();
        responseVO.setCode(HttpStatus.INTERNAL_SERVER_ERROR.value());
        responseVO.setMsg(msg);
        return responseVO;
    }

    public static ResponseVO error(String msg, Integer code){
        ResponseVO responseVO = new ResponseVO();
        responseVO.setCode(code);
        responseVO.setMsg(msg);
        return responseVO;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
